<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="金西振">
    <title></title>
    <style>
        .box {
            width: 520px;
            height: 280px;
            margin: 100px auto;
            position: relative;
        }
        
        ul {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        
        li {
            position: absolute;
            top: 0;
            left: 0;
            display: none;
        }
        
        li.current {
            display: block;
        }
        
        .yuan {
            left: 150px;
            top: 240px;
            border-radius: 15px;
            width: 230px;
            background-color: lightgray;
            display: flex;
            flex-direction: row;
            position: relative;
        }
        
        .yuan .yuan1 {
            background-color: red;
        }
        
        .yuan section {
            margin-left: 20px;
            border-radius: 15px;
            width: 20px;
            height: 20px;
            background-color: white;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li class="current">
                <a href="#"><img src="./img/01.jpg" alt=""></a>
            </li>
            <li>
                <a href="#"><img src="./img/02.jpg" alt=""></a>
            </li>
            <li>
                <a href="#"><img src="./img/03.jpg" alt=""></a>
            </li>
            <li>
                <a href="#"><img src="./img/04.jpg" alt=""></a>
            </li>
            <li>
                <a href="#"><img src="./img/05.jpg" alt=""></a>
            </li>
        </ul>
        <div class="yuan">
            <section class="yuan1">
                <a href="#"></a>
            </section>
            <section>
                <a href="#"></a>
            </section>
            <section>
                <a href="#"></a>
            </section>
            <section>
                <a href="#"></a>
            </section>
            <section>
                <a href="#"></a>
            </section>
        </div>
    </div>

</body>

</html>
<script>
    var lis = document.querySelectorAll('li');
    var sections = document.querySelectorAll('section');
    var index = 0;
    setInterval(changeImage, 1000);
    function changeImage() {
        for (var a = 0; a < sections.length; a++) {
            sections[a].className = '';
        }
        for (var i = 0; i < lis.length; i++) {
            lis[i].className = '';
        }
        index++;
        if (index == 5) {
            index = 0
        }
        lis[index].className = 'current';
        sections[index].className = 'yuan1';
    }

</script>